import { registerAppMenu } from '@/app'
import { setInteraction } from '@/map-interaction'
import { registerAuxGraphicType } from '../core'
import { toPolygon, type AuxSector, toFeature } from './core'
import { DrawAuxSector } from './draw-aux-sector'
import AuxSectorInfoVue from './AuxSectorInfo.vue'

export function setupAuxSector() {
  registerAuxGraphicType<AuxSector>({
    type: 'Sector',
    typeName: '辅助扇形',
    geometry: (e) => [toPolygon(e)],
    feature: toFeature,
    component: AuxSectorInfoVue
  })
  registerAppMenu({
    path: '工具/地图Aux:绘制辅助扇形',
    onClick() {
      setInteraction(new DrawAuxSector(true))
    }
  })
  registerAppMenu({
    path: '工具/地图Aux:绘制辅助扇形[逆时针]',
    onClick() {
      setInteraction(new DrawAuxSector(false))
    }
  })
}
